package cn.hr.entity;


import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * 用户实体类
 */
@Entity
@Table(name="tb_user"
    ,catalog="hrm"
)

public class User  implements java.io.Serializable {


    // Fields    

     /**
	 * 
	 */
	private static final long serialVersionUID = -3213540826077461569L;
	private Long id;
     private Role role;
     private String userName;
     private String password;
     private Set<Article> articles = new HashSet<Article>(0);
     private Set<Student> students = new HashSet<Student>(0);


    // Constructors

    /** default constructor */
    public User() {
    }

	/** minimal constructor */
    public User(Role role, String userName, String password) {
        this.role = role;
        this.userName = userName;
        this.password = password;
    }
    
    /** full constructor */
    public User(Role role, String userName, String password, Set<Article> articles, Set<Student> students) {
        this.role = role;
        this.userName = userName;
        this.password = password;
        this.articles = articles;
        this.students = students;
    }

   
    // Property accessors
    @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)

    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="userRoleId", nullable=false)

    public Role getRole() {
        return this.role;
    }
    
    public void setRole(Role role) {
        this.role = role;
    }
    
    @Column(name="userName", nullable=false, length=24)

    public String getUserName() {
        return this.userName;
    }
    
    public void setUserName(String userName) {
        this.userName = userName;
    }
    
    @Column(name="password", nullable=false, length=16)

    public String getPassword() {
        return this.password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")

    public Set<Article> getArticles() {
        return this.articles;
    }
    
    public void setArticles(Set<Article> articles) {
        this.articles = articles;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")

    public Set<Student> getStudents() {
        return this.students;
    }
    
    public void setStudents(Set<Student> students) {
        this.students = students;
    }
   








}